this._stream = null;
this._volumeCancellable = null;
+ this._icons = [];
}
get stream() {
if (!this._stream)
return null;
- let icons = ["audio-volume-muted-symbolic",
- "audio-volume-low-symbolic",
- "audio-volume-medium-symbolic",
- "audio-volume-high-symbolic",
- "audio-volume-overamplified-symbolic"];
-
let volume = this._stream.volume;
let n;
if (this._stream.is_muted || volume <= 0) {
n = 0;
} else {
n = Math.ceil(3 * volume / this._control.get_vol_max_norm());
- if (n < 1)
- n = 1;
- else if (n > 3)
- n = 4;
+ n = Math.clamp(n, 1, this._icons.length - 1);
}
- return icons[n];
+ return this._icons[n];
}
getLevel() {
constructor(control) {
super(control);
this._slider.accessible_name = _("Volume");
+ this._icons = [
+ 'audio-volume-muted-symbolic',
+ 'audio-volume-low-symbolic',
+ 'audio-volume-medium-symbolic',
+ 'audio-volume-high-symbolic',
+ 'audio-volume-overamplified-symbolic',
+ ];
}
_connectStream(stream) {
this._control.connect('stream-added', this._maybeShowInput.bind(this));
this._control.connect('stream-removed', this._maybeShowInput.bind(this));
this._icon.icon_name = 'audio-input-microphone-symbolic';
+ this._icons = [
+ 'microphone-sensitivity-muted-symbolic',
+ 'microphone-sensitivity-low-symbolic',
+ 'microphone-sensitivity-medium-symbolic',
+ 'microphone-sensitivity-high-symbolic',
+ ];
}
_connectStream(stream) {
this._output = new OutputStreamSlider(this._control);
this._output.connect('stream-updated', () => {
- this.emit('icon-changed');
+ this.emit('output-icon-changed');
});
this.addMenuItem(this._output.item);
this._input.item.connect('notify::visible', () => {
this.emit('input-visible-changed');
});
+ this._input.connect('stream-updated', () => {
+ this.emit('input-icon-changed');
+ });
this.addMenuItem(this._input.item);
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this._readInput();
this._readOutput();
} else {
- this.emit('icon-changed');
+ this.emit('output-icon-changed');
}
}
this._input.stream = this._control.get_default_source();
}
- getIcon() {
+ getOutputIcon() {
return this._output.getIcon();
}
+ getInputIcon() {
+ return this._input.getIcon();
+ }
+
getLevel() {
return this._output.getLevel();
}
this._control = getMixerControl();
this._volumeMenu = new VolumeMenu(this._control);
- this._volumeMenu.connect('icon-changed', () => {
- let icon = this._volumeMenu.getIcon();
+ this._volumeMenu.connect('output-icon-changed', () => {
+ let icon = this._volumeMenu.getOutputIcon();
if (icon != null)
this._primaryIndicator.icon_name = icon;
this._primaryIndicator.visible = icon !== null;
});
- this._inputIndicator.set({
- icon_name: 'audio-input-microphone-symbolic',
- visible: this._volumeMenu.getInputVisible(),
- });
+ this._inputIndicator.visible = this._volumeMenu.getInputVisible();
this._volumeMenu.connect('input-visible-changed', () => {
this._inputIndicator.visible = this._volumeMenu.getInputVisible();
});
+ this._volumeMenu.connect('input-icon-changed', () => {
+ let icon = this._volumeMenu.getInputIcon();
+
+ if (icon !== null)
+ this._inputIndicator.icon_name = icon;
+ });
this.menu.addMenuItem(this._volumeMenu);
}
if (result == Clutter.EVENT_PROPAGATE || this.menu.actor.mapped)
return result;
- let gicon = new Gio.ThemedIcon({ name: this._volumeMenu.getIcon() });
+ let gicon = new Gio.ThemedIcon({ name: this._volumeMenu.getOutputIcon() });
let level = this._volumeMenu.getLevel();
let maxLevel = this._volumeMenu.getMaxLevel();
Main.osdWindowManager.show(-1, gicon, null, level, maxLevel);